import request from '@/utils/request'

// 人员管理

/**
 * 获取列表
 *
 * @export
 * @param {*} data { keyword, deptId, status }
 * @returns
 */
export function fetchAccountFindPage(data) {
  return request({
    url: '/pc/base/account/findPage',
    method: 'post',
    data
  })
}

/**
 * 获取详情
 *
 * @export
 * @param {*} params { id }
 * @returns
 */
export function fetchAccountGet(params) {
  return request({
    url: '/pc/base/account/get',
    method: 'get',
    params
  })
}

/**
 * 添加
 *
 * @export
 * @param {*} data { name, phone, idNumber, account, sex, birth, nativePlace, bloodType, address,
                     educationalLevel, linkman, linkmanPhone, deptId, postId, dutyDate, contractExpirationDate,
                     contractType, roleId, insuranceTypeList, deviceIdStr, allowLoginPc, status }
 * @returns
 */
export function fetchAccountAdd(data) {
  return request({
    url: '/pc/base/account/add',
    method: 'post',
    data
  })
}

/**
 * 更新
 *
 * @export
 * @param {*} data { name, phone, idNumber, account, sex, birth, nativePlace, bloodType, address,
                     educationalLevel, linkman, linkmanPhone, deptId, postId, dutyDate, contractExpirationDate,
                     contractType, roleId, insuranceTypeList, deviceIdStr, allowLoginPc, status }
 * @returns
 */
export function fetchAccountUpdate(data) {
  return request({
    url: '/pc/base/account/update',
    method: 'post',
    data
  })
}

/**
 * 删除
 *
 * @export
 * @param {*} data { id }
 * @returns
 */
export function fetchAccountDelete(params) {
  return request({
    url: '/pc/base/account/delete',
    method: 'post',
    params
  })
}

/**
 * 更新状态
 *
 * @export
 * @param {*} params { status, id }
 * @returns
 */
export function fetchAccountStatusUpdate(params) {
  return request({
    url: '/pc/base/account/updateStatus',
    method: 'post',
    params
  })
}

/**
 * 修改密码
 *
 * @export
 * @param {*} data { oldPassword, newPassword }
 * @returns
 */
export function fetchChangePassword(params) {
  return request({
    url: '/pc/base/account/changePassword',
    method: 'post',
    params
  })
}

/**
 * 重置密码
 *
 * @export
 * @param {*} params { id }
 * @returns
 */
export function fetchResetPassword(params) {
  return request({
    url: '/pc/base/account/resetPassword',
    method: 'post',
    params
  })
}

export const AccountImportUrl = '/api/pc/base/account/accountImport'
/**
 * 员工信息导入
 *
 * @export
 * @param {*} params { file, orgId }
 * @returns
 */
export function fetchAccountImport(params) {
  return request({
    url: '/pc/base/account/accountImport',
    method: 'post',
    params,
    formatRes: true
  })
}

/**
 * 导出员工数据
 *
 * @export
 * @param {*} params
 * @returns
 */
export function fetchAccountExport(params) {
  return request({
    url: '/pc/base/account/exportAccount',
    method: 'get',
    params,
    responseType: 'blob',
    getResponse: true,
    download: true,
    onlyFile: true
  })
}

// 模板下载
export function fetchDownloadTemplate() {
  return request({
    url: '/pc/base/account/accountTemplate',
    method: 'get',
    responseType: 'blob',
    getResponse: true,
    download: true,
    onlyFile: true
  })
}
